<?php
require_once 'models/models_chungloai.php';
$mod = $_GET['mod'];
$obcl = new models_chungloai();
require_once 'models/models_loaihang.php'; //goi trang model loai hang
$oblh = new models_loaihang(); //khoi tao doi tuong loai hang
switch ($mod){
	case 'loaihang':{
		
		$data['listcl'] = $obcl->listchungloai();
		$data['list'] = $oblh->listLoaiHang();
		include_once 'views/admin/loaihang/index.php';
		break;
	}
	case 'addloaihang':{
		if($_POST){
			$oblh->addLoaiHang($_POST['cmb_choice'], $_POST['tenlh']);
			echo '<script> window.location.href="admin.php?mod=loaihang"</script>';
		}
		$data['list'] = $obcl->listchungloai(); //lay danh sach chung loai hang
		require 'views/admin/loaihang/add.php';
		break;
	}
	case 'delloaihang':{
		$oblh->delLoaiHang($_GET['ma']);
		echo '<script> window.location.href="admin.php?mod=loaihang"</script>';
		break;
	}

	case 'updateloaihang':{
		if($_POST){
		$oblh->updateLoaiHang($_POST['cmb_choice'],$_POST['tenlh'],$_GET['ma']);
				echo '<script>window.location.href="admin.php?mod=loaihang"</script>';
			}
		$data = $oblh->getLoaiHang($_GET['ma']);
		$data['listcl'] = $obcl->listchungloai();
		require 'views/admin/loaihang/edit.php';
		break;
	}
	default: echo 'yeu cau chua duoc xu ly !'; break;
}
?>